package com.roselism.jd.fragment;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;

import com.roselism.jd.R;

public abstract class BaseFragment extends Fragment {
    // TODO: Rename parameter arguments, choose names that match
    // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
    public static final String ARG_PARAM1 = "param1";
    public static final String ARG_PARAM2 = "param2";

    // TODO: Rename and change types of parameters
    private String mParam1;
    private String mParam2;

    public BaseFragment() {
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if (getArguments() != null) {
            mParam1 = getArguments().getString(ARG_PARAM1);
            mParam2 = getArguments().getString(ARG_PARAM2);
        }
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fragment_base, container, false);
        FrameLayout toolbar = (FrameLayout) view.findViewById(R.id.fragment_toolbar);
        FrameLayout contentView = (FrameLayout) view.findViewById(R.id.fragment_content);

        if (getToolbar() != null) toolbar.addView(getToolbar());
        if (getContentView() != null) contentView.addView(getContentView());
        return view;
    }

    /**
     * 获取内容view
     *
     * @return
     */
    public abstract View getContentView();

    /**
     * 获取顶部view
     *
     * @return
     */
    public abstract View getToolbar();

    @Override
    public void onDetach() {
        super.onDetach();
    }
}
